package com.lamda.worker.config;

import com.lamda.worker.utils.WorkerUtils;
import org.springframework.stereotype.Component;

import java.io.UnsupportedEncodingException;

/**
 * Created by MJiao on 11/22/14.
 */
@Component
public class ApplicationSettings {

   // @Value("${master.port}")
    private int masterSeverPort;

    //@Value("${master.ip}")
    private String masterIp;

    /**
     *
     */
    //@Value("${worker.ip}")
    private String workerIp;


    //@Value("${worker.hostname}")
    private String workerHostname;

    //@Value("${worker.remark}")
    private String remark;


    public int getMasterSeverPort() {
        return masterSeverPort;
    }

    public void setMasterSeverPort(int masterSeverPort) {
        this.masterSeverPort = masterSeverPort;
    }

    public String getMasterIp() {
        return masterIp;
    }

    public String getWorkerIp() {
        return workerIp;
    }

    public void setWorkerIp(String workerIp) {
        this.workerIp = workerIp;
    }

    public void setMasterIp(String masterIp) {
        this.masterIp = masterIp;
    }

    public String getWorkerHostname() {
        return workerHostname;
    }

    public void setWorkerHostname(String workerHostname) {
        this.workerHostname = workerHostname;
    }

    public String getRemark() {
        String encoding = WorkerUtils.getEncoding(this.remark);
        try {
          return new String(this.remark.getBytes(encoding),"UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Override
    public String toString() {
        return "ApplicationSettings{" +
                "masterSeverPort=" + masterSeverPort +
                ", masterIp='" + masterIp + '\'' +
                ", workerIp='" + workerIp + '\'' +
                ", workerHostname='" + workerHostname + '\'' +
                ", remark='" + remark + '\'' +
                '}';
    }
}
